Remove HTMLCanvasElement test mock #12020
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes most test failures reported by Jest's new --detectLeaks feature
Note: I wasn't able to see any measurable difference in heap usage using --logHeapUsage so this probably isn't as big of a deal as it would seem, just good to fix if we can
Details
Now that detectLeaks works in Jest 22, I ran it on the React repo and found that ~110/130 tests report leaks. That number is approximate because some tests leak intermittently
After investigating the leaks, I found that 1 line accounted for ~100 of the leaks. Removing this line reduces the failures from ~110 to ~10.
It looks like assigning a function to any window attribute inside setupEnvironment will leak the Window after the test due to the setupEnvironment closure. I've filed a bug in Jest here
Testing
Running this command:
yarn test --detectLeaksBefore
After
Note: a good file to test this with which will reliably fail on master and work on this branch is
invertObject-test.js. These test could be inenv=nodeyet this like still leaks Window object:yarn test --detectLeaks invertObject-test.js